var pageNum = null;
var pageSize = 5;
let vm = new Vue({
    el: '.main-content',
    data: {
        pageInfo: {}
    },
    methods: {

        getPage: function (pageNum, pageSize) {
            selectPage(pageNum, pageSize)
        },

        toUpdate: function (id) {
            layer.open({
                type: 2,
                skin: 'layui-layer-demo', //样式类名
                title: '编辑',
                closeBtn: 1, //不显示关闭按钮
                anim: 2,
                area: ['80%', '50%'],
                shadeClose: true, //开启遮罩关闭
                content: '/guguanjia/demand/toUpdate',
                success: function (layero, index) {
                    var iframe = window['layui-layer-iframe' + index];
                    iframe.child(id, index);
                }
            });
        },


        toUpdate2: function (id) {
            layer.open({
                type: 2,
                skin: 'layui-layer-demo',
                title: '编辑',
                closeBtn: 0,
                anim: 2,
                area: ['80%', '80%'],
                shadeClose: true,
                content: '/guguanjia/demand/toUpdate2',
                success: function (layero, index) {
                    var iframe = window['layui-layer-iframe' + index];
                    iframe.child(id, index);
                },
                end: function () {
                    selectPage(pageNum, pageSize);
                    layer.msg("更新成功");
                }
            });
        }


    },
    created: function () {
        selectPage(1, 5);
    }

});

function selectPage(pageNum, pageSize) {
    this.pageNum = pageNum;
    this.pageSize = pageSize;
    axios({
        url: `/guguanjia/demand/findAll/${pageNum}/${pageSize}`,
    }).then(response => {
        vm.$data.pageInfo = response.data;
    }).catch(error => {
        console.log(error.message)
    })
}